#       testXML.py
#       
#       Copyright 2008 Joshua Scotton <josh@joshuascotton.com>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

__licence__ = "GPLv2"
__copyright__ = "2008, Joshua Scotton"
__author__ = "Joshua Scotton <josh@joshuascotton.com>"

import unittest
import sys
import os

sys.path += [os.path.abspath('..')]

from Challenge import Challenge, Entry, Item
from xml.dom import minidom

class TestToXML(unittest.TestCase):
    def setUp(self):
        self.challenge01 = Challenge()
        self.challenge01.setup("Test Challenge", "0020")
        self.challenge01.addType("TestItem", "Organic")
        self.challenge01.addEntryItem("TheArtist", "TheFile.jpg", 0, "TheSource.blend")
        self.challenge01.addEntryItem("TheArtist", "TheFile2.jpg", 0, "TheSource2.blend")
        self.challenge01.addEntryItem("TheArtist2", "TheFile3.jpg", 0, "TheSource3.blend")
        self.challenge02 = Challenge()
        
    def testIt01(self):
        self.challenge02.loadFromXML(minidom.parseString(self.challenge01.toXML()))
        print self.challenge01.toXML()
        print self.challenge02.toXML()
        self.assertEqual(self.challenge01.toXML(), self.challenge02.toXML())
    
    def testIt02(self):
        self.challenge01.voting_thread_link = "voting_thread_link_test"
        self.challenge01.entry_thread_link = "entry_thread_link_test"
        self.challenge02.loadFromXML(minidom.parseString(self.challenge01.toXML()))
        self.assertEqual(self.challenge01.toXML(), self.challenge02.toXML())
